package cz.vargarob.spring.test;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

import org.apache.commons.logging.Log;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;

public class LifecycleTestBean implements InitializingBean, DisposableBean{

	private String requiredProperty;
	private String optionalProperty;
	
	@Autowired
	private Log myLog;
	
	@PostConstruct
	public void init(){
		myLog.info("LIFECYCLE_ Calling INIT method");
	}
	
	@PreDestroy
	public void finish(){
		myLog.info("LIFECYCLE_ Calling FINISH method");
	}
	
	public void start(){
		myLog.info("LIFECYCLE_ Calling START method");
	}
	
	public void stop(){
		myLog.info("LIFECYCLE_ Calling STOP method");
	}
	
	public void afterPropertiesSet() throws Exception {
		myLog.info("LIFECYCLE_ Calling AFTER PROPS SET method");
	}

	public void destroy() throws Exception {
		myLog.info("LIFECYCLE_ Calling DESTROY method");
	}
	
	public LifecycleTestBean() {
	}

	public Log getMyLog() {
		return myLog;
	}

	public void setMyLog(Log myLog) {
		this.myLog = myLog;
	}

	public String getRequiredProperty() {
		return requiredProperty;
	}

	@Required
	public void setRequiredProperty(String requiredProperty) {
		this.requiredProperty = requiredProperty;
	}

	public String getOptionalProperty() {
		return optionalProperty;
	}

	public void setOptionalProperty(String optionalProperty) {
		this.optionalProperty = optionalProperty;
	}

}
